package com.itheima;

public class demo07 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int i = 0;
        int j = arr.length - 1;
        boolean ishead = true;
        while (i < j) {
            if (ishead) {
                if (arr[i] % 2 == 1) {
                    i++;
                } else {
                    ishead = false;
                }
            }
            if (ishead == false) {
                if (arr[j] % 2 == 0) {
                    j--;
                } else {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                    i++;
                    ishead = true;
                }
            }
        }
        for (int k = 0; k < arr.length; k++) {
            System.out.println(arr[k]);
        }
    }
}
